<template>
  <div>
    <headNav :isBack="false" :isHome="false" title="通知详情" ></headNav>
    <div class="flexColumn bigDivCss" >
      <span>{{pictureNew.inOutTime}}</span>
      <img :src="pictureNew.img" >
      <span>*{{pictureNew.remark}}</span>
      <div class="flexCenter" style="margin-top: 0.3rem;" v-if="personalData.Type == 1 && !pictureNew.isModify" >
        <button class="button-1" type="default" @click="positiveClick">平台误报</button>
        <button class="button-2" type="default" @click="abnormalClick" >确认异常</button>
      </div>
    </div>
  </div>
</template>


<script>
import headNav from '@/components/headNav/headNav.vue'
import { XTable, XSwitch, XButton  } from 'vux'
import { mapActions, mapState, mapGetters, mapMutations } from 'vuex'
import {singleExceptionApi, pushParentsApi, positiveApi} from '@/api/payApi'
export default {
  components: {
    headNav,
    XTable,
    XSwitch,
    XButton
  },
  data () {
    return {
      pictureNew: '',  // 存放图片以及提示
      personalData: ''
    }
  },
  async mounted() {
    this.getPersonalDetails()
  },
  methods: {
    async positiveClick () {
      await positiveApi(this.personalData.inOutRecordId)
      this.$vux.toast.text('操作成功', 'middle')
      this.getPersonalDetails()
    },
    async abnormalClick () {
      await pushParentsApi(this.personalData.inOutRecordId)
      this.$vux.toast.text('异常确认成功', 'middle')
      this.getPersonalDetails()
    },
    // 获取个人异常详情封装
    async getPersonalDetails () {
      // location.search
      var search =  location.search  // ?a=1&b=2
      search = search.replace("?", '')  // a=1&b=2
      var arr = search.split("&")  // ["a=1", "b=2"]
      var obj = {}
      for(var item of arr) {
        var list = item.split("=") // ['a', "1"]
        obj[list[0]] = list[1]
      }
      console.log(obj)
      this.personalData = obj
      // obj = {a:1, b:2}
      let valinOutRecordId = ''
      let valinOutAbnormalId = ''
      if (this.personalData.inOutRecordId) {
        valinOutRecordId = this.personalData.inOutRecordId
        valinOutAbnormalId = ''
      }
      if (this.personalData.inOutAbnormalId) {
        valinOutRecordId = ''
        valinOutAbnormalId = this.personalData.inOutAbnormalId
      }
      // '0052f285-4015-68a8-fa12-39f4f66ebcc0'
      let params = {
        // InOutRecordId: this.personalData.inOutRecordId,
        // IOutAbnormalId: this.personalData.inOutAbnormalId
        InOutRecordId: valinOutRecordId,
        IOutAbnormalId: valinOutAbnormalId
      }
      let res = await singleExceptionApi(params)
      this.pictureNew = res
      console.log(res)
    }
  }
}
</script>

<style scoped lang="less" >
.flexCenter {
  display: flex;
  justify-content: center;
}

.flexColumn {
  display: flex;
  flex-direction: column;
}

.bigDivCss {
  margin: 0.5rem 0.3rem 0 0.3rem;
  font-weight: 500;
  font-size: 0.3rem;
  img {
    max-width: 7rem;
    margin: 0.3rem 0;
  }
}

.button-1 {
  width: 3.25rem;
  height: 0.8rem;
  border: 1px #128FEF solid;
  color: #128FEF;
  background: #FFF;
  border-radius: 0.1rem;
  font-size: 0.3rem;
  margin-right: 0.3rem;
}

.button-2 {
  width: 3.25rem;
  height: 0.8rem;
  border: 1px solid #128FEF;
  color: #ffffff;
  background: #128FEF;
  border-radius: 0.1rem;
  font-size: 0.3rem;
}
</style>
